<?php
/**
 * ===============================================
 * 版权所有 2019-2050 青岛铁锤科技有限公司，并保留所有权利。
 * 网站地址: http://www.huaxianling.com
 * ===============================================
 * Author: Happy dong
 * Created Time: 2019-06-25 14:00
 * Modified Time: 2019-06-25 14:00
 * Version: 2.0
 */

namespace App\Models;


use Illuminate\Database\Eloquent\Model;

/**
 * Class DynamicImage 理发师动态的图
 * @package App\Models
 * Author: Happy dong
 * Created Time: 2019-06-25 14:10
 */
class DynamicResource extends Model
{
	protected $table = 'dynamic_resource';

	protected $guarded = [];

	public function imgOrVideoUrl()
	{
		if($this->type == config('constant.resourceType.picture')) {
			return $this->hasOne(Picture::class, 'id', 'resource_id');
		} else {
			return $this->hasOne(Video::class, 'id', 'resource_id');
		}
	}

}